<template>
	<z-paging ref="paging" :refresher-out-rate="0.8" :show-empty-view-reload-when-error="false"
		:empty-view-img-style="{ width: '308rpx', height: '308rpx' }"
		empty-view-error-img="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/1c53b8aed0c74201bb092265803a1d48.png"
		empty-view-img="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/987eadb1d50949a0a7e25dbbd99abe30.png"
		empty-view-error-text="暂无数据" safe-area-inset-bottom bg-color="#fff" v-model="dataList" @query="queryList">
		<view slot="top" class="topTabbar">
			<u-text prefixIcon="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2024/06/25/67811ef09f754e7ea5224a01a2856283.png" iconStyle="width:48rpx;height:48rpx;margin-right:16rpx;" :text="details.egg_total" color="#3D3D3D" size="72rpx" align="center" />
			<u-text :text="'满'+details.egg_exchange_limit+'个可领取'" color="#777777" size="28rpx" align="center" margin="32rpx 0 30rpx" />
			<u-tabs :current="currentTab" :list="tabList" @change="tabChange" :scrollable="false"></u-tabs>
		</view>
		<view class="cellBox" v-for="(item, index) in dataList" :key="index" >
			<view class="cellBox_item flex_wrap row_between row_middle">
				<u-text :text="$u.timeFormat(item.create_time, 'yyyy-mm-dd hh:MM')" color="#3D3D3D" size="32rpx" />
				<u-text :text="item.number + '个'" color="#777777" size="32rpx" align="right" />
			</view>
		</view>
	</z-paging>
</template>

<script>
	import {
		list
	} from "@/api/mybookSalesman.js";
	import {
		chickUrl
	} from "@/config/tendIdConfig.js"
	import { encryption } from "@/utils/encryption.js";
	export default {
		data() {
			return {
				tabList: [{
						name: "福鸡鸡蛋",
						id: 0,
					},
					{
						name: "领取记录",
						id: 1,
					},
				],
				currentTab: 0,
				dataList: [],
				phone:'',
				details:{}
			};
		},
		onLoad(options) {
			 this.phone = options.phone;
		},
		methods: {
			async tabChange(e) {
				this.currentTab = e.index;
				await this.$refs.paging.reload();
			},
			async queryList(pageNo, pageSize) {
				this.getDetail()
				const that = this;
				uni.request({
				   url: chickUrl + '/api/v1/open/chick-food/user-egg-log',
					method: "GET",
					header: {
						Authorization: `Bearer ${that.token}`,
					},
					data: {
						...encryption({
						    page : pageNo,
							per_num : pageSize,
							user_account : this.phone,
							source:this.currentTab ? '2' : '1'
						}),
					},
					success(res) {
					   const result = res.data.data
					   that.$refs.paging.completeByTotal(result.list, result.total);
					},
				});
			},
			async getDetail() {
				const that = this;
				uni.request({
				   url: chickUrl + '/api/v1/open/chick-food/user-chick-property',
					method: "GET",
					header: {
						Authorization: `Bearer ${that.token}`,
					},
					data: {
						...encryption({
							user_account : this.phone,
						}),
					},
					success(res) {
					   that.details = res.data.data
					   console.log(that.details,'result1>>')
					},
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.topTabbar {
		background-color: #fff;
		padding-bottom: 16rpx;
		padding-top: 46rpx;
	}

	.cellBox {
		width: 90vw;
		margin: 0 auto;
		&_item{
			height: 108rpx;
			border-bottom: 1rpx solid #D8D8D8;
		}
	}
</style>